Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / core / service / src / androidMain / kotlin / org / meshtastic / core / service / BootCompleteReceiver.kt

Displaying Raw • Download

core/service/src/androidMain/kotlin/org/meshtastic/core/service/BootCompleteReceiver.kt 2d20cd8a4708e2ef66e98d5259f3a97ec93f240a (2d20cd8a) Text, 2.53 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.service

Tff7b72import T7ee787android.content.BroadcastReceiver
Tff7b72import T7ee787android.content.Context
Tff7b72import T7ee787android.content.Intent
Tff7b72import T7ee787co.touchlab.kermit.Logger
Tff7b72import T7ee787org.koin.core.component.KoinComponent
Tff7b72import T7ee787org.koin.core.component.inject
Tff7b72import T7ee787org.meshtastic.core.repository.MeshPrefs

T8b949e/** This receiver starts the MeshService on boot if a device was previously connected. */
Tff7b72class T56d364BootCompleteReceiver Tb4b4b4:
Te6edf3BroadcastReceiverTb4b4b4(Tb4b4b4)Tb4b4b4,
Te6edf3KoinComponent Tb4b4b4{

Tff7b72private Tff7b72val Te6edf3meshPrefsTb4b4b4: Te6edf3MeshPrefs Tff7b72by Te6edf3injectTb4b4b4(Tb4b4b4)

Tff7b72override Tff7b72fun Td2a8ffonReceiveTb4b4b4(Te6edf3contextTb4b4b4: Te6edf3ContextTb4b4b4, Te6edf3intentTb4b4b4: Te6edf3IntentTb4b4b4) Tb4b4b4{
T8b949e// Only these two actions carry a background foreground-service-start exemption. The manifest also filters the
T8b949e// OEM quick-boot actions, which do not, so acting on those would guarantee a rejected start.
Tff7b72if Tb4b4b4(Te6edf3intentTb4b4b4.Te6edf3action Tff7b72!in Te6edf3EXEMPT_ACTIONSTb4b4b4) Tb4b4b4{
Te6edf3LoggerTb4b4b4.Te6edf3d Tb4b4b4{ Ta5d6ff"Ta5d6ffBootCompleteReceiver: ignoring non-exempt action Tffd700${Te6edf3intentTb4b4b4.Te6edf3actionTffd700}Ta5d6ff" Tb4b4b4}
Tff7b72return
Tb4b4b4}
Tff7b72val Te6edf3address Tff7b72= Te6edf3meshPrefsTb4b4b4.Te6edf3deviceAddressTb4b4b4.Te6edf3value
Tff7b72if Tb4b4b4(Te6edf3addressTb4b4b4.Te6edf3isNullOrBlankTb4b4b4(Tb4b4b4) Tff7b72|Tff7b72| Te6edf3addressTb4b4b4.Te6edf3equalsTb4b4b4(Ta5d6ff"Ta5d6ffnTa5d6ff"Tb4b4b4, Te6edf3ignoreCase Tff7b72= Tff7b72trueTb4b4b4)Tb4b4b4) Tb4b4b4{
Te6edf3LoggerTb4b4b4.Te6edf3d Tb4b4b4{ Ta5d6ff"Ta5d6ffBootCompleteReceiver: no device previously connected, skipping service startTa5d6ff" Tb4b4b4}
Tff7b72return
Tb4b4b4}

Te6edf3LoggerTb4b4b4.Te6edf3i Tb4b4b4{ Ta5d6ff"Ta5d6ffBootCompleteReceiver: starting MeshService after Tffd700${Te6edf3intentTb4b4b4.Te6edf3actionTffd700}Ta5d6ff" Tb4b4b4}
Te6edf3MeshServiceTb4b4b4.Te6edf3startServiceTb4b4b4(Te6edf3contextTb4b4b4, Te6edf3ServiceStartTriggerTb4b4b4.Te6edf3BootCompletedTb4b4b4)
Tb4b4b4}

Tff7b72private Tff7b72companion Tff7b72object Tb4b4b4{
T8b949e/**
* `MY_PACKAGE_REPLACED` is filtered by the manifest so an in-place upgrade restores the radio link without
* waiting for the user to reopen the app, and it is exempt from the background-start restriction just as
* `BOOT_COMPLETED` is.
*/
Tff7b72val Te6edf3EXEMPT_ACTIONS Tff7b72= Te6edf3setOfTb4b4b4(Te6edf3IntentTb4b4b4.Te6edf3ACTION_BOOT_COMPLETEDTb4b4b4, Te6edf3IntentTb4b4b4.Te6edf3ACTION_MY_PACKAGE_REPLACEDTb4b4b4)
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.04s